function countMaxZeroSubMatrix() : longint;

var     
	i, j : longint;
	d, d1, d2 : array[0..1010] of longint;
	st : stack;

begin
	result := 0;
	fillchar(d, sizeof(d), -1);
	for i := 0 to nn do begin
		for j := 0 to mm do
			if a[i][j] then d[j] := i;
		st.init();
		for j := 0 to mm do begin
			while (not st.empty()) and (d[st.top()] <= d[j]) do st.pop();
			if st.empty() then d1[j] := -1 else d1[j] := st.top();
			st.push(j);
		end;
		st.init();
		for j := mm downto 0 do begin
			while (not st.empty()) and (d[st.top()] <= d[j]) do st.pop();
			if st.empty() then d2[j] := y else d2[j] := st.top();
			st.push(j);
		end;
		for j := 0 to mm do
			result := max(result, (i - d[j]) * (d2[j] - d1[j] - 1));
	end;
end;